#ifndef SP_TASK_TASK_H
#define SP_TASK_TASK_H

#include <task/tss.h>
#include <system/term.h>
#include <klibc/ctype.h>

// Task priority values
#define TASK_PRIORITY_HIGH	1
#define TASK_PRIORITY_HMED	2
#define TASK_PRIORITY_MED	3
#define TASK_PRIORITY_LMED	4
#define TASK_PRIORITY_LOW	5


typedef struct task_p
{
	// Stato del processo
	tss_t cpu_state;
	
	//
	uint32_t owner;
	uint32_t group;
	uint8_t priority;
	
	// Id del processo
	uint32_t pid;
	
	// Terminale del processo
	term_t *term;
	
	// Nome del processo
	char name[32];
	char path[128];
	
	uint32_t cpu_usage;
	uint32_t mmu_usage;
	char *env[128];
	char *argv[128];
	
	// successivo task
	struct task_p *next;	
} task_t;

uint32_t task_num;
task_t *task_list;
task_t *task_current;

void (*task_switching_func); 

void task_switch_to_user_mode();
void task_init();
void task_switch();
uint32_t task_fork();
void task_exit();
void task_out(char *);
uint32_t task_exec(char *, char *, char *[], char *[]);
uint8_t task_ifexist(char *);
void task_print_list();

// Metodi di switching
void task_switch_round_robin();
void task_switch_priority();


#endif
